
#include "Log.h"
#include <sstream>
#include<Windows.h>
using namespace yssdk;
CLog::CLog(void)
{
}


CLog::~CLog(void)
{
}
bool CLog::openLog(std::string filename)
{
        //m_outfile.open(filename,std::ios::app|std::ios::out);
        m_outfile.open(filename.c_str(),std::ios::app|std::ios::out);
	return true;
}
void CLog::LogTime(std::string &str)
{
	 SYSTEMTIME sysTime;
	GetLocalTime(&sysTime);
	std::string temp;
	std::stringstream  fuck;
	str="\n*******************************";
	fuck<<sysTime.wYear;
	fuck>>temp;
	str+=temp;
	str+="_";
	
	
	fuck.clear();
	fuck<<sysTime.wMonth;
	fuck>>temp;
	str+=temp;
	str+="_";

	fuck.clear();
	fuck<<sysTime.wDay;
	fuck>>temp;
	str+=temp;
	str+="_";

	fuck.clear();
	fuck<<sysTime.wHour;
	fuck>>temp;
	str+=temp;
	str+=":";

	fuck.clear();
	fuck<<sysTime.wMinute;
	fuck>>temp;
	str+=temp;
	str+="**********************************\n";
	
}
void CLog::writeLog(std::string text)
{
	std::string log;
	LogTime(log);
	log+=text;
	m_outfile<<log;
	m_outfile.flush();
}
